<?php
session_start();
$email=$_SESSION['email'];
 include('databaseconnection.php');
 $letter='K';
if(isset($_SESSION['lang']))
{
$lang=$_SESSION['lang'];
if($lang=="English - Tamil")
	{
		$lan='Tamil';
	}
	if($lang=="English - Sinhala")
	{
		$lan='Sinhala';
	}
	
 $query = "SELECT * FROM terms WHERE language='$lan' AND (term LIKE 'k%' or term LIKE 'K%' ) ";   
}
else
{

$query = "SELECT * FROM terms WHERE term LIKE 'k%' or term LIKE 'K%'";  }

include ("header2.php");
  
$result = mysql_query($query);

if (mysql_num_rows($result) >= 1) 
  {
  
echo   "<table width='100%' height='82' border='1' class='table' align='left'>
<tr bgcolor='#FFFFFF'>


<th >Term</th>
<th>Domain</th>
<th>Accepted Meaning</th>
<th>Language</th>





<th>More</th>
<th>Likes</th>

<th>Votes</th>
</tr>";
while($row=mysql_fetch_array($result))
{
echo "<tr>";


echo "<td width='20%'>".$row['term']."</td>";
$term=$row['term'];
echo "<td width='15%'>".$row['domain']."</td>";
$acc_mean=$row['accepted_meaning'];

echo "<td width='35%'>".$row['accepted_meaning']."</td>";
echo "<td width='15%'>".$row['language']."</td>";


//echo "<td width='5%'><input type='submit' name='$term' value='more'/>";
//echo "</form>";

//echo "<td width='28%'>".$row['comments']."</td>";

//echo "<td width='10%'><textarea rows='1' cols='9' name='comm'></textarea><input type='submit' name='$term' value='update comment'/><input type='hidden' name='butt' value='$term'</td>";
//echo "<td width='10%'><textarea rows='1' cols='9' name='addsugg'></textarea><input type='submit' name='$term' value='add suggestion'/><input type='hidden' name='butt' value='$term'</td>";


$resultlike=mysql_query("SELECT * FROM liketable where email='$email' AND term='$term' AND accepted_meaning='$acc_mean' ");
if(!$result) echo "invalid";
if (mysql_num_rows($resultlike) == 1) 
  {


$like='Unlike';
echo "<td width='3%'><a href='like.php?li=$term.$acc_mean.$like'>Unlike</a></td>";
//echo "<td width='5%'><input type='submit' name='$term' value='Unlike'/>";
}
else
{
//echo "<td width='3%'><a href='like.php'>like</a></td>";
$like='like';
//echo "<td width='5%'><input type='submit' name='$term' value='like'/>";
echo "<td width='3%'><a href='like.php?li=$term.$acc_mean.$like'>like</a></td>";
}
//echo "<input type='hidden' name='butt' value='$term'>";
//echo "<input type='hidden' name='butt1' value='$acc_mean'>";
//echo "<input type='hidden' name='like' value='$like'>";
$votes=$row['votes'];
echo "<td width='7%'><a href='votes.php?err=$term.$acc_mean'>".$votes."</a></td>";
echo "<td width='3%'><a href='moredetails.php?li=$term.$acc_mean'>More</a></td>";


echo "</tr>";
}

echo "</table>";  
} 
else
{  
 echo   "<table width='960px' height='82' border='1' class='table' align='left'>";
   echo "<tr><td>No results for your search</td></tr>";
   echo "</table>";  
}   

include ('footer.php');
?>




